<?php
/**
 * PHP version 5
 * @copyright  Samsun Xu 2009
 * @package    Frontend
 * @license    LGPL
 * @get product list
 */
session_start();
define('TL_ROOT', dirname(__FILE__));

require_once('system/config/localconfig.php');

class getCityList
{	
	public function run()
	{
		$str  = $this->getCityList();
		echo $str;
	}
	
	public function getCityList()
	{
		$pid = $_POST['province'];
		$this->setDB();
		$sql		= "SELECT * FROM `china_city` where pid = $pid ORDER BY city_en asc";
		$result 	= @mysql_query($sql);
		
		$cityHtml	= "<option value=\"\" selected=\"selected\">Please select city</option>\n";
		
		while ($objRd = @mysql_fetch_assoc($result)){
			$city_name = stripslashes(trim($objRd['city_en']));
			$cityHtml .= "<option value=\"".$objRd['id']."\">$city_name</option>\n";		
		}
		
		return $cityHtml;
	}

	public function setDB()
	{
		$strHost = $GLOBALS['TL_CONFIG']['dbHost'];
		if($GLOBALS['TL_CONFIG']['dbPort']){
			$strHost .= ':' . $GLOBALS['TL_CONFIG']['dbPort'];
		}

		if($GLOBALS['TL_CONFIG']['dbPconnect']){
			$resConnection = @mysql_pconnect($strHost, $GLOBALS['TL_CONFIG']['dbUser'], $GLOBALS['TL_CONFIG']['dbPass']);
		}else{
			$resConnection = @mysql_connect($strHost, $GLOBALS['TL_CONFIG']['dbUser'], $GLOBALS['TL_CONFIG']['dbPass']);
		}

		if (is_resource($resConnection)){
			@mysql_query("SET sql_mode=''", $resConnection);
			@mysql_query("SET NAMES " . $GLOBALS['TL_CONFIG']['dbCharset'], $resConnection);
			@mysql_select_db($GLOBALS['TL_CONFIG']['dbDatabase'], $resConnection);
		}
	}	
	
}

$objGetRd = new getCityList();
$objGetRd->run();

?>